export const state = () => ({
  locationCity: undefined,
  // 酒店列表数据
  searchData: {
    city: undefined,
    enterTime: undefined,
    leftTime: undefined,
    // person: undefined, // 暂时不用
    price_in: undefined,
    hotellevel: [],
    hoteltype: [],
    hotelbrand: [],
    hotelasset: [],
    _start: 0,
    _limit: 6
  },
  total: 0,
})

export const mutations = {
  setLocationCity (state, cityName) {
    state.locationCity = cityName
  },
  setCityId (state, cityId) {
    state.searchData.city = cityId
  },
  setEnterTime (state, enterTime) {
    state.searchData.enterTime = enterTime
  },
  setLeftTime (state, leftTime) {
    state.searchData.leftTime = leftTime
  },
  setPriceIn (state, price_in) {
    state.searchData.price_in = price_in
  },
  setHotellevel (state, hotellevel) {
    state.searchData.hotellevel = hotellevel
  },
  setHotelType (state, hoteltype) {
    state.searchData.hoteltype = hoteltype
  },
  setHotelAsset (state, hotelasset) {
    state.searchData.hotelasset = hotelasset
  },
  setHotelBrand (state, hotelbrand) {
    state.searchData.hotelbrand = hotelbrand
  },
  setLimit (state, _limit) {
    state.searchData._limit = _limit
  },
  setStart (state, _start) {
    state.searchData._start = _start
  },
  resetSearchData (state) {
    state.searchData = {
      city: undefined,
      enterTime: undefined,
      leftTime: undefined,
      price_in: undefined,
      hotellevel: [],
      hoteltype: [],
      hotelbrand: [],
      hotelasset: [],
      _start: 0,
      _limit: 6
    }
  },
  resetFilter (state) {
    state.searchData.price_in = undefined
    state.searchData.hotellevel = []
    state.searchData.hoteltype = []
    state.searchData.hotelbrand = []
    state.searchData.hotelasset = []
    state.searchData._start = 0
  },
  setTotal (state, total) {
    state.total = total
  }
}
